﻿using EMall.ProductService.Brands;
using EMall.Query;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace EMall.ProductService.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class BrandController : ControllerBase, IBrandAppService
    {
        private readonly IBrandAppService _brandAppService;
        public BrandController(IBrandAppService brandAppService)
        {
            _brandAppService = brandAppService;
        }
        [HttpPost]
        public async Task CreateAsync(CreateBrandDto input)
        {
            await _brandAppService.CreateAsync(input);
        }
        [HttpPut]
        public async Task UpdateAsync(UpdateBrandDto input)
        {
            await _brandAppService.UpdateAsync(input);
        }
        [HttpDelete]
        public async Task DeleteAsync(DeleteBrandDto input)
        {
            await _brandAppService.DeleteAsync(input);
        }
        [HttpGet]
        public async Task<BrandDto> GetAsync(int id)
        {
            return await _brandAppService.GetAsync(id);
        }
        [HttpGet]
        public async Task<IEnumerable<BrandListDto>> GetListAsync([FromQuery] GetBrandListQueryDto input)
        {
            return await _brandAppService.GetListAsync(input);
        }
        [HttpGet]
        public async Task<IPagedList<BrandListDto>> GetPagedListAsync([FromQuery] GetBrandListPagingAndSortingQueryDto input)
        {
            return await _brandAppService.GetPagedListAsync(input);
        }
    }
}
